package com.qf.controller;

import com.qf.service.DtsSearchHistoryService;
import com.qf.util.ResponseUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**  用户管理  搜索历史
 * @author bss
 * @version V1.0
 * @Project maven
 * @Package com.qf.controller
 * @Description:
 * @Date 2022/10/16 21:11
 */
@RestController
@RequestMapping("/admin/history")
public class AdminHistoryController {

    @Autowired
    DtsSearchHistoryService searchHistoryService;
//    admin/history/list?page=1&limit=20&userId=11&keyword=%E7%9C%8B&sort=add_time&order=desc

    @GetMapping("/list")
    public Object list(@RequestParam(value = "page",required = false, defaultValue = "1") Integer page,
                       @RequestParam(value = "limit",required = false, defaultValue = "20")Integer limit,
                       @RequestParam(value = "sort",required = false, defaultValue = "add_time")String sort,
                       @RequestParam(value = "order",required = false, defaultValue = "desc")String order,
                       Integer userId, String keyword){


        Map<String , Object> data = searchHistoryService.selectByPage(page,limit,sort,order,userId,keyword);

//        SELECT id,user_id,keyword,`from`,add_time,update_time,deleted   FROM (SELECT  id,user_id,keyword,`from`,add_time,update_time,deleted  FROM dts_search_history
//                WHERE (deleted = 0)) AS a  ORDER BY add_time DESC LIMIT 1,20
        return ResponseUtil.ok(data);

    }


}
